{% extends 'base.html' %}

{% block title %}编辑个人资料 - EasyTesting{% endblock %}

{% block header %}编辑个人资料{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-body p-4">
                <form method="post">
                    {% csrf_token %}

                    {% if form.errors %}
                    <div class="alert alert-danger">
                        <i class="bi bi-exclamation-triangle-fill me-2"></i>
                        请修正以下错误:
                        <ul class="mb-0 mt-2">
                            {% for field in form %}
                                {% for error in field.errors %}
                                <li>{{ field.label }}: {{ error }}</li>
                                {% endfor %}
                            {% endfor %}
                        </ul>
                    </div>
                    {% endif %}

                    <div class="row mb-4">
                        <div class="col-md-6">
                            <label for="{{ form.first_name.id_for_label }}" class="form-label fw-medium">名字</label>
                            {{ form.first_name.errors }}
                            <input type="text" class="form-control" id="{{ form.first_name.id_for_label }}" name="{{ form.first_name.html_name }}" value="{{ form.first_name.value|default:'' }}">
                        </div>

                        <div class="col-md-6">
                            <label for="{{ form.last_name.id_for_label }}" class="form-label fw-medium">姓氏</label>
                            {{ form.last_name.errors }}
                            <input type="text" class="form-control" id="{{ form.last_name.id_for_label }}" name="{{ form.last_name.html_name }}" value="{{ form.last_name.value|default:'' }}">
                        </div>
                    </div>

                    <div class="mb-4">
                        <label for="{{ form.email.id_for_label }}" class="form-label fw-medium">电子邮件</label>
                        {{ form.email.errors }}
                        <input type="email" class="form-control" id="{{ form.email.id_for_label }}" name="{{ form.email.html_name }}" value="{{ form.email.value|default:'' }}" required>
                    </div>

                    <div class="d-flex justify-content-between mt-4">
                        <a href="{% url 'profile' %}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left"></i> 返回
                        </a>
                        <button type="submit" class="btn btn-primary px-4">
                            <i class="bi bi-check-lg"></i> 保存更改
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}
